/*
 * @Author: HeAo
 * @Date: 2021-10-29 11:30:20
 * @LastEditTime: 2021-10-29 11:51:39
 * @LastEditors: HeAo
 * @Description:
 * @FilePath: \web2103-2105\web2103code\4-1-Nodejs\day01\sms\index.js
 * 别乱动！
 */
// 导入内置模块
let url = require('url')
let qs = require('querystring')

// 加载学生管理模块中的方法
let { findAllStudent, deleteStudentById } = require('./modules/students')
let { findAllCoures, deleteCourseById } = require('./modules/course')

// const request1 = 'http://47.94.46.113:8002/student/findAll'
const request1 = 'http://47.94.46.113:8002/student/deleteById?id=5'
const request2 = 'http://47.94.46.113:8002/student/deleteById?id=5'

let urlObj1 = url.parse(request1)
let urlObj2 = url.parse(request2)

console.log(urlObj1);
console.log(urlObj2);

if (urlObj1.pathname == '/student/findAll') {
  findAllStudent()
} else if (urlObj1.pathname == '/student/deleteById') {
  const id = qs.parse(urlObj1.query).id
  deleteStudentById(id)
}